package com.axjy.scheduler.config;

import com.axjy.comm.util.TpConst;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    @Bean
    public Exchange scheduleExchange(){
        return ExchangeBuilder.directExchange(TpConst.SCHEDULE_EXCHANGE)
                .durable(true).build();
    }

    @Bean
    public Queue orderQueue(){
        return QueueBuilder.durable(TpConst.ORDER_QUEUE).build();
    }

    @Bean
    public Binding  bindOrderToSchedule(){
        return BindingBuilder.bind(orderQueue())
                .to(scheduleExchange())
                .with(TpConst.SCHEDULE_ORDER_BINDING).noargs();
    }




}
